package com.zuoshenge.sys.config;

import com.zuoshenge.sys.bean.JwtProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;  
import org.springframework.context.annotation.Configuration;  
  
@Configuration  
public class JwtConfig {  
  
    @Value("${jwt.header}")  
    private String header;  
  
    @Value("${jwt.token-start-with}")  
    private String tokenStartWith;  
  
    @Value("${jwt.base64-secret}")  
    private String base64Secret;  
  
    @Value("${jwt.token-validity-in-seconds}")  
    private long tokenValidityInSeconds;  
  
    @Value("${jwt.online-key}")  
    private String onlineKey;  
  
    @Value("${jwt.code-key}")  
    private String codeKey;  
  
    @Value("${jwt.detect}")  
    private long detect;
  
    @Value("${jwt.renew}")  
    private long renew;

    @Value("${jwt.remember-me-base64-secret}")
    private String rememberMeBase64Secret;

    @Value("${jwt.remember-me-key}")
    private String rememberMeKey;

    @Value("${jwt.remember-me-token-validity-in-seconds}")
    private Long rememberMeTokenValidityInSeconds;


    @Bean  
    public JwtProperties jwtProperties() {
        JwtProperties jwtProperties = new JwtProperties();
        jwtProperties.setHeader(header);  
        jwtProperties.setTokenStartWith(tokenStartWith);  
        jwtProperties.setBase64Secret(base64Secret);  
        jwtProperties.setTokenValidityInSeconds(tokenValidityInSeconds);  
        jwtProperties.setOnlineKey(onlineKey);  
        jwtProperties.setCodeKey(codeKey);  
        jwtProperties.setDetect(detect);
        jwtProperties.setRenew(renew);
        jwtProperties.setRememberMeBase64Secret(rememberMeBase64Secret);
        jwtProperties.setRememberMeKey(rememberMeKey);
        jwtProperties.setRememberMeTokenValidityInSeconds(rememberMeTokenValidityInSeconds);
        return jwtProperties;  
    }  
}